﻿

    <div ms-controller="tempview">
    <div class="sui-form form-inline">
        <label>省：</label>
        <select class="input-xfat" ms-duplex="Province" ms-change="GetCity()">
            <option ms-repeat-el="cityData1" ms-attr-value="el.CValue">{{el.CValue}}</option>
        </select>
        <label>市：</label>
        <select class="input-xfat" ms-duplex="City" ms-change="GetCounty()">
            <option ms-repeat-el="cityData2" ms-attr-value="el.CValue">{{el.CValue}}</option>
        </select>
        <label>区/县：</label>
        <select class="input-xfat" ms-duplex="County">
            <option ms-repeat-el="cityData3" ms-attr-value="el.CValue">{{el.CValue}}</option>
        </select>
        <a class="sui-btn btn-large btn-primary" style="margin-left:10px;" ms-click="GetLIST()">查询</a>
        <a style="margin-left:10px;" class="sui-btn btn-large btn-success" ms-click="ADD('')">添加</a>
    </div>
    <table class="sui-table table-primary table-zebra">
  <thead>
    <tr>
      <th>用户名</th>
      <th>所属地区</th>
      <th>级别</th>
      <th>创建时间</th>
      <th></th>
    </tr>
  </thead>
  <tbody>
    <tr ms-repeat-el="ListData">
      <td>{{el.UserName}}</td>
      <td>{{el.Province+el.City+el.County}}</td>
      <td>{{ShowLvl(el.Lvl)}}</td>
      <td>{{el.CRTime|date('yyyy-MM-dd')}}</td>
      <td>
          <a href="javascript:void(0);" class="sui-btn btn-bordered btn-small btn-success" ms-click="ADD(el)">修改</a>
          <a href="javascript:void(0);" class="sui-btn btn-bordered btn-small btn-danger" ms-click="DEL(el)">删除</a>
      </td>
    </tr>

  </tbody>
</table>

    <div id="pageDiv"></div>

    </div>

  <script type="text/javascript">
      var tempmodel = avalon.define({
          $id: "tempview",
          search: {},
          page: { pageindex: 1, pagecount: 10 },
          ShowColumns: [],
          ListData: [],
          APINAME: "",
          Operation: "",
          GetLIST: function () {
              ComFunJS.getJSON("BASE_GETAUTHUSERLIST", { pageindex: tempmodel.page.pageindex, Province: model.Province, City: model.City, County: model.County }, function (r) {
                  if (r.error == "") {
                      tempmodel.ListData = r.result;

                      $("#pageDiv").pagination({  //分页容器
                          styleClass: ['sui-pagination'],  //分页样式
                          //showCtrl: false,
                          displayPage: 6,
                          itemsCount: r.total,
                          pageSize: tempmodel.page.pagecount,
                          onSelect: function (num) {
                              tempmodel.page.pageindex = num;
                              ComFunJS.getJSON("BASE_GETAUTHUSERLIST", { pageindex: tempmodel.page.pageindex, Province: model.Province, City: model.City, County: model.County }, function (r) {
                                  tempmodel.ListData.clear();
                                  tempmodel.ListData = r.result;
                              })
                          }
                      })

                      $('#pageDiv').pagination('updateItemsCount', r.total, 1);
                  }
              })
          },
          DEL: function (el) {
              ComFunJS.winShowConfirm("确认删除吗", function () {
                  ComFunJS.getJSON("BASE_DELAUTHUSER", { P1: el.ID }, function (r) {
                      tempmodel.ListData.remove(el);
                  })
              })
             
          },
          ShowLvl: function (lvl) {

              if (lvl == 1) {
                  return "省级";
              } else if (lvl == 2) {
                  return "市级";
              } else if (lvl == 3) {
                  return "县级";
              }
              return lvl;
          }
      })
      avalon.ready(function () {

          tempmodel.GetLIST();
         
      })

      
  </script>
